import 'package:flutter/material.dart';
import 'package:ui_templates/app_theme.dart';

class FeedBackPage extends StatefulWidget {
  const FeedBackPage({super.key});

  @override
  State<FeedBackPage> createState() => _FeedBackPageState();
}

class _FeedBackPageState extends State<FeedBackPage> {
  TextEditingController _controller = TextEditingController();

  @override
  Widget build(BuildContext context) {
    var isLight = MediaQuery.of(context).platformBrightness == Brightness.light
        ? true
        : false;
    return Scaffold(
      body: Padding(
        padding: EdgeInsets.symmetric(horizontal: 30),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Container(
              child: Image.asset(
                "assets/images/feedbackImage.png",
                fit: BoxFit.contain,
              ),
            ),
            Container(
              height: 50,
              alignment: Alignment.center,
              child: Text(
                "Your FeedBack",
                style: TextStyle(
                  color: isLight ? AppTheme.darkText : AppTheme.white,
                  fontSize: 20,
                  fontWeight: FontWeight.bold,
                ),
              ),
            ),
            Container(
              height: 30,
              alignment: Alignment.center,
              child: Text(
                "Give your best time for this moment",
                style: TextStyle(
                  color: isLight ? AppTheme.grey : AppTheme.white,
                  fontSize: 14,
                ),
              ),
            ),
            createScrollableTextField(),
            Padding(
              padding: const EdgeInsets.only(top: 15.0),
              child: Container(
                width: 130,
                height: 40,
                decoration: BoxDecoration(
                  boxShadow: [
                    BoxShadow(
                      color: Colors.grey.withOpacity(.5),
                      blurRadius: 1,
                      spreadRadius: 1,
                      offset: const Offset(4, 3),
                    ),
                  ],
                  borderRadius: const BorderRadius.all(
                    Radius.circular(10),
                  ),
                ),
                child: Material(
                  color: Colors.transparent,
                  child: InkWell(
                    child: ElevatedButton(
                      style: const ButtonStyle(
                        elevation: MaterialStatePropertyAll<double>(5),
                      ),
                      onPressed: () {
                        print(123);
                      },
                      child: const Text("Send"),
                    ),
                    onTap: () {
                      FocusScope.of(context).requestFocus(FocusNode());
                    },
                  ),
                ),
              ),
            )
          ],
        ),
      ),
    );
  }

  Widget createScrollableTextField() {
    return Container(
      constraints: const BoxConstraints(
        minHeight: 80,
        maxHeight: 160,
      ),
      decoration: BoxDecoration(
        color: AppTheme.white,
        boxShadow: [
          BoxShadow(
            color: Colors.grey.withOpacity(.6),
            blurRadius: 2,
            spreadRadius: 3,
            offset: Offset(3, 3),
          )
        ],
        borderRadius: const BorderRadius.all(
          Radius.circular(20),
        ),
      ),
      child: SingleChildScrollView(
        padding: const EdgeInsets.fromLTRB(10, 10, 10, 0),
        child: TextFormField(
          controller: _controller,
          decoration: const InputDecoration(
            hintText: "Enter your feedback...",
            hintStyle: TextStyle(
              color: Colors.grey,
            ),
            border: InputBorder.none,
          ),
          maxLines: null,
        ),
      ),
    );
  }
}
